#ifndef NETWORKCARDWIDGET_H
#define NETWORKCARDWIDGET_H

#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPainter>

class NetworkCardWidget : public QWidget {
    Q_OBJECT
public:
    enum ViewMode {
        TileMode,      // 平铺模式，图标在左，文字在右
        LargeIconMode  // 大图标模式，图标在上，文字在下
    };

    explicit NetworkCardWidget(const QPixmap &icon, const QString &name, const QString &desc, const QString &status, QWidget *parent = nullptr);
    void setSelected(bool selected);
    void setViewMode(ViewMode mode);
    virtual QSize sizeHint() const override;
    void updateData(const QPixmap &icon, const QString &name, const QString &desc, const QString &status);
protected:
    void paintEvent(QPaintEvent *event) override;
    void enterEvent(QEvent *event) override;
    void leaveEvent(QEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;
private:
    QLabel *iconLabel;
    QLabel *nameLabel;
    QLabel *descLabel;
    QLabel *statusLabel;
    bool m_selected = false;
    bool m_hovered;
    ViewMode m_viewMode;
    bool m_firstLayout = true;

    QHBoxLayout *m_tileLayout;
    QVBoxLayout *m_largeIconLayout;
    QVBoxLayout *m_textLayout;
    QLayout *m_currentMainLayout;

    QPixmap m_originalIcon;
    QString m_originalName;
    QString m_originalDesc;
    QString m_originalStatus;
    QPixmap m_currentIcon; // 当前icon，用于切换视图时保持最新图标
};

#endif // NETWORKCARDWIDGET_H 